<?php
/**
 * @package WordPress
 * @subpackage Starkers
 */
?>
<div id="action">
<ul id="subNav">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
<?php 
// use wp_list_pages to display parent and all child pages all generations (a tree with parent)
$parent = $post->post_parent;
$args=array(
  'title_li' =>	'',
  'child_of' => $parent,
  'sort_column' => 'menu_order'
);
wp_list_pages( $args ); ?>
</ul>

<div class="tabs">

<?php
	global $post;
$content = $post->post_name;
$args = array(
	'tag' => $content,
	'category_name' => 'Sidebar'
);

	query_posts($args);
 ?>
		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>	

<a href="<?php 
global $post;
$postID = $post->ID;
$postgotoID = get_post_meta($postID, 'pageID', true);

if ( empty($postgotoID) ) {
$posttitle = $post->post_title;
$page = get_page_by_title( $posttitle );
$page_id = $page->ID;
$link = get_page_link($page_id);
echo $link;
} 
else {
$link = get_page_link($postgotoID);
echo $link;
}
?>">
<?php
global $post;
$content = $post->post_content;
echo $content
?>
</a>
<?php endwhile; endif; ?>
</div>

<?php wp_reset_query(); ?>
<div class="list">
<?php
global $post;
$content = $post->post_name;
$args = array(
	'tag' => $content,
	'category_name' => 'Sidebar-list'
);

	query_posts($args);
 ?>
		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>	
		<?php the_content(); ?>
		<?php endwhile; endif; ?>
</div>
</div><!-- action -->
		